<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use app\common\model\System;

class Setting extends AdminBase
{
    /**
     * 系统配置
     * @return mixed
     */
    public function index($key='')
    {
        if ($this->request->isPost()) {
            $param = $this->request->param();
            System::where('key',$key)->update(['jdata'=>$param['data']]);
            cache($key,null);
            if($param['key'] == 'wxpay'){
                System::writeCertPemFiles($param['certpem'], $param['keypem']);
            }
            $this->result('',0,"设置成功");
        }
        $data = System::where('key',$key)->find()['jdata'];
        $this->result($data);
    }



}
